import java.util.Objects;
class Person{
    public int id;
    public Person(int id){
        this.id = id;
    }
}

public class HashBuck2 <K, V>{
    class Node<K, V>{
        public K key;
        public V value;
        public Node<K, V> next;

        public Node(K key, V value){
            this.key = key;
            this.value = value;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Node<?, ?> node = (Node<?, ?>) o;
            return Objects.equals(key, node.key) && Objects.equals(value, node.value) && Objects.equals(next, node.next);
        }

        @Override
        public int hashCode() {
            return Objects.hash(key, value, next);
        }
    }
    public Node<K, V> [] array;
    public int usedSize;
    public HashBuck2(){
        array = (Node<K, V> []) new Node[10];
    }

    public void put(K key, V value){
        int index = key.hashCode() % array.length;
        Node<K, V> cur = array[index];
        //若已经有这个key则将value值进行更新
        while(cur != null){
            if(cur.key == key){
                cur.value = value;
            }
            cur = cur.next;
        }
        Node<K, V> node = new Node<>(key, value);
        node.next = array[index];
        array[index] = node;
        usedSize++;
    }
    public V get(K key){
        int index = key.hashCode() % array.length;
        Node<K, V> cur = array[index];
        while(cur != null){
            if(cur.key == key){
                return cur.value;
            }
            cur = cur.next;
        }
        return null;
    }
}
